let vm = new Vue({
    el:'#app',  //选中整个main
    data:{
        user:{
            email:'',
            password:''
        },//初始化对象
        code:''
    },
    methods:{
        changePassword:function () {
            if (this.user.email===undefined||this.user.email.length<=0){
                layer.msg("邮箱不能为空！！！");
            }else {
                axios.put(`user/forget/${this.code}`,this.user).then(res=>{
                    if (res.data.success){
                        layer.msg(res.data.msg);
                        location.href='index.html';
                    }else {
                        layer.msg(res.data.msg);
                    }
                }).catch(error=>{
                    layer.msg(error.message)
                });
            }
        },
        sendCode:function () {      //发送邮箱验证码
            axios.get(`email/send/${this.user.email}`).then(res=>{
                if (res.data.success){
                    layer.msg(res.data.msg);
                }else {
                    layer.msg("发送验证码失败");
                }
            }).catch(error=>{
                layer.msg(error.message)
            });
        }
    },
});